package com.sports.common.util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;

/**
 * @ClassName IdGenerateUtil
 * @Desciption
 * @Author MaRui
 * @address https://maruinotes.com
 * @Date 2021/11/20 10:28
 * @Version 1.0
 */
public class IdGenerateUtil {

    /**
     * 指定前缀生成 id
     * @return
     */
    public static String prefix(String code) {
        String uuid = UUID.randomUUID().toString().substring(0, 5);
        String yyyyMMdd = LocalDateTime.now().format(DateTimeFormatter.BASIC_ISO_DATE);

        return code + yyyyMMdd + uuid;
    }

    /**
     * 获取随机UUID
     *
     * @return 随机UUID
     */
    public static String randomUUID()
    {
        return UUID.randomUUID().toString().replace("-", "");
    }
}
